﻿using System;
using System.Collections.Generic;
using LightWeb.BlogCore;
using LightWeb.BlogCore.Provider;
using LightWeb.Infrastructure.Repositories;

namespace LightWeb.Application.Provider
{
    class NHBlogProvider : BlogProvider
    {
        public override void DeleteBlog(BlogCore.Blog blog)
        {
            throw new NotImplementedException();
        }

        public override bool DeleteBlogStorageContainer(BlogCore.Blog blog)
        {
            throw new NotImplementedException();
        }

        public override void DeleteCategory(BlogCore.Category category)
        {
            throw new NotImplementedException();
        }

        public override void DeletePage(BlogCore.Page page)
        {
            throw new NotImplementedException();
        }

        public override void DeletePost(BlogCore.Post post)
        {
            throw new NotImplementedException();
        }

        public override List<BlogCore.Blog> FillBlogs()
        {
            throw new NotImplementedException();
        }

        public override List<BlogCore.Category> FillCategories()
        {
            throw new NotImplementedException();
        }

        public override List<BlogCore.Page> FillPages()
        {
            throw new NotImplementedException();
        }

        public override List<BlogCore.Post> FillPosts()
        {
            throw new NotImplementedException();
        }

        public override IDictionary<string, IEnumerable<string>> FillRights()
        {
            throw new NotImplementedException();
        }

        public override void InsertBlog(BlogCore.Blog blog)
        {
            throw new NotImplementedException();
        }

        public override void InsertCategory(BlogCore.Category category)
        {
            throw new NotImplementedException();
        }

        public override void InsertPage(BlogCore.Page page)
        {
            throw new NotImplementedException();
        }

        public override void InsertPost(BlogCore.Post post)
        {
            using (OurTransactionScope ts = new OurTransactionScope())
            {
                var context = DataContext.Current;
                DomainModel.Post model = new DomainModel.Post()
                {
                    BlogID = post.Id,
                    PostID = post.Id,
                    Title = post.Title,
                    Description = post.Description ?? string.Empty,
                    Content = post.Content,
                    Created = post.DateCreated.AddHours(-BlogSettings.Instance.Timezone),
                    Modified = (post.DateModified == new DateTime() ? DateTime.Now : post.DateModified.AddHours(-BlogSettings.Instance.Timezone)),
                    Author = post.Author,
                    Published = post.IsPublished,
                    CommentEnabled = post.HasCommentsEnabled,
                    Raters = post.Raters,
                    Rating = post.Rating,
                    Slug = post.Slug,
                    IsDeleted = post.IsDeleted
                };
                ts.Complete();
            }
        }

        public override void SaveRights(IEnumerable<BlogCore.Right> rights)
        {
            throw new NotImplementedException();
        }

        public override BlogCore.Blog SelectBlog(Guid id)
        {
            throw new NotImplementedException();
        }

        public override BlogCore.Category SelectCategory(Guid id)
        {
            throw new NotImplementedException();
        }

        public override BlogCore.Page SelectPage(Guid id)
        {
            throw new NotImplementedException();
        }

        public override BlogCore.Post SelectPost(Guid id)
        {
            throw new NotImplementedException();
        }

        public override bool SetupBlogFromExistingBlog(BlogCore.Blog existingBlog, BlogCore.Blog newBlog)
        {
            throw new NotImplementedException();
        }

        public override void UpdateBlog(BlogCore.Blog blog)
        {
            throw new NotImplementedException();
        }

        public override void UpdateCategory(BlogCore.Category category)
        {
            throw new NotImplementedException();
        }

        public override void UpdatePage(BlogCore.Page page)
        {
            throw new NotImplementedException();
        }

        public override void UpdatePost(BlogCore.Post post)
        {
            throw new NotImplementedException();
        }
    }
}
